package com.asset.service.impl;

import com.asset.mapper.PurchaseMapper;
import com.asset.model.dto.purchase.PurchaseQueryRequest;
import com.asset.model.entity.purchase.Purchase;
import com.asset.model.entity.purchase.Purchase_P;
import com.asset.model.vo.AssetVO;
import com.asset.model.vo.PurchaseVo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class PurchaseServiceImpl {
	@Autowired
	private PurchaseMapper purchaseMapper;
	public PageInfo<Purchase> getPurchaseByCompanyAndAll(PurchaseQueryRequest request) {
		List<Purchase> purchaseByCompanyAndAll = purchaseMapper.getPurchaseByCompanyAndAll(request);

//		List<Purchase> collect = purchaseByCompanyAndAll.stream()
//				.map( purchase-> {
//					Purchase vo = new Purchase();
//					vo.setId(purchase.getId());   //  ID
//					vo.setPurchaseAll(purchase.getPurchaseAll());
//					vo.setApplicationTime(purchase.getApplicationTime());
//					vo.setCompany(purchase.getCompany());
//					vo.setCompanyId(purchase.getCompanyId());
//					vo.setStatus(purchase.getStatus());
//					vo.setSource(purchase.getSource());
//					vo.setTotalAmount(purchase.getTotalAmount());
//					vo.setBudgetApplicationId(purchase.getBudgetApplicationId());
//					return vo;
//				})
//				.collect(Collectors.toList());// 转换为列表

		return new PageInfo<Purchase>(purchaseByCompanyAndAll);

	}
}
